package br.com.felix.fwt.svg.group;

import java.util.ArrayList;
import java.util.List;

import br.com.felix.fwt.svg.SVG;
import br.com.felix.fwt.svg.SVGBuilder;
import br.com.felix.fwt.svg.SVGColor;
import br.com.felix.fwt.svg.SVGId;
import br.com.felix.fwt.svg.transform.SVGTransform;

public class SVGGroup implements SVG {

	private SVGId id;

	private SVGColor fill;

	private Float opacity;

	private List<SVG> children;

	private Integer strokeWidth;
	
	private SVGColor stroke;
	
	private SVGTransform transform;

	public SVGGroup() {
		children = new ArrayList<SVG>();
	}



	@Override
	public void toSVG(SVGBuilder svgBuilder) {
		svgBuilder.createElement("g")
			.id(id)
			.attribute("fill", fill)
			.attribute("opacity", opacity)
			.attribute("stroke-width", strokeWidth)
			.attribute("stroke", stroke)
			.attribute("transform", transform)
			.bodyWithChildren(children)
			.endElement();
	}



	public SVGGroup strokeWidth(int i) {
		this.strokeWidth = i;
		return this;
	}



	public SVGGroup stroke(SVGColor stroke) {
		this.stroke = stroke;
		return this;
	}



	public SVGGroup transform(SVGTransform svgt) {
		this.transform = svgt;
		return this;
	}



	public void add(SVG...svgs) {
		for(SVG child: svgs){
			children.add(child);
		}
	}



	public void addAll(List<SVG> children) {
		this.children.addAll(children);		
	}

}
